package com.qing.study.serviceImpl;

import com.qing.study.service.AsyncService;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
public class AsyncServiceImpl implements AsyncService {
    //通过@Async注解告诉spring这是个异步任务，开启异步功能，前台页面无需等待很久
    @Async
    @Override
    public void asyncMethod() {
        try {
            Thread.sleep(3000);
            System.out.println("数据正在处理...");
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
